package com.example.administrator.szb.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.administrator.szb.R;
import com.example.administrator.szb.activity.base.BaseActivity;
import com.example.administrator.szb.http.URLAddress;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by D N on 2017/11/23.
 */

public class GZXYActivity extends BaseActivity {
    @Bind(R.id.gzxy_webview)
    WebView gzxyWebview;
    String title;
    int id;
    String url = URLAddress.HOST_PORT+"/api/Htmlview/mobilepub?id=";
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gzxy_activity);
        ButterKnife.bind(this);
        title = getIntent().getStringExtra("title");
        id = getIntent().getIntExtra("id",-1);
         //url = URLAddress.URL_XY+id;
        url  = url+id;
        //
        if (id==4){
            //url = URLAddress.URL_SERVICE_BOOK;
            title = "市值宝服务协议";
            url=URLAddress.HOST_PORT+"/home/staticpub/userdeal";
            initToolbar(R.id.gzxy_toolbar_include,""+title);
        }else if (id==1){
            //url = URLAddress.URL_ABLUT_US;
            title = "关于我们";
            initToolbar(R.id.gzxy_toolbar_include,""+title);
        }else if (id==2){
            //url = URLAddress.URL_SERVICE_BOOK;
            title = "保密承诺";
            initToolbar(R.id.gzxy_toolbar_include,""+title);
        }else if (id==3){
            //url = URLAddress.URL_ABLUT_3;
            title = "执行承诺";
            initToolbar(R.id.gzxy_toolbar_include,""+title);
        }else if (id==5){
            //url = URLAddress.URL_ABLUT_2;
            title = "金融顾问公约";
            initToolbar(R.id.gzxy_toolbar_include,""+title);
        }else {

        }

        requestData();
    }

    private void requestData() {

        /*WebSettings webSettings = gzxyWebview.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setUseWideViewPort(true);//關鍵點
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        gzxyWebview.setInitialScale(200);*/

        gzxyWebview.loadUrl(url);
        gzxyWebview.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
    }
}
